package com.xyd.servlet;

import com.xyd.entity.Comment;
import com.xyd.service.CommentService;
import com.xyd.service.impl.CommentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 86186
 */
@WebServlet("/CommentUpdateReplyServlet")
public class CommentUpdateReplyServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String ecIdStr=request.getParameter("ecId");
        long ecId=Long.parseLong(ecIdStr);
        String ecReply=request.getParameter("ecReply");

        Comment comm=new Comment();
        comm.setEcId(ecId);
        comm.setEcReply(ecReply);
        CommentService commentService=new CommentServiceImpl();
        Boolean flag=commentService.updateReplyComment(comm);

        if (flag){
            request.getRequestDispatcher("CommentServlet?pageIndex=0").forward(request,response);
        }
        else {
            response.sendRedirect("guestbook-modify.jsp");
        }

    }
}
